package flashSecurityServer.handler;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;


public class PolicyFileLoader {
	public static final String POLICY_FILE_REQUEST_HEADER="<policy-file-request/>";

	public static String POLICY_FILE_PATH="policyfile.xml";

	private static String __prolicyFileContent="";

	public static String getPolicyFileContent(){
		return __prolicyFileContent+"\0";
	}

	public static void loadPolicyFile() throws Exception {
		InputStream stream=ClassLoader.getSystemResourceAsStream(POLICY_FILE_PATH);
		byte[] bytes=new byte[stream.available()]	;

//		String policy=new String();
//		policy="<?xml version=\"1.0\"?>"
//			+"<cross-domain-policy>"
//			+"<allow-access-from domain=\"*\" to-ports=\"*\"/>"
//			+"</cross-domain-policy>";
//		byte[] bytes=policy.getBytes();
		stream.read(bytes);
		__prolicyFileContent=new String(bytes).trim();
		stream.close();
//		__prolicyFileContent=policy;
		System.out.println("Policy file loaded");
	}
}
